package com.hurui.xiaoming.weight;

import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.view.Gravity;
import android.view.WindowManager;
import android.widget.ImageView;

import com.hurui.xiaoming.R;


public class ProgressTips extends Dialog {
	
	public ProgressTips(Context context) {
		super(context);
	}

	public ProgressTips(Context context, int theme) {
		super(context, theme);
	}


	public void onWindowFocusChanged(boolean hasFocus){
		ImageView imageView = (ImageView)findViewById(R.id.pro_tips);
        AnimationDrawable spinner = (AnimationDrawable) imageView.getBackground();
        spinner.start();
    }
	
	public static ProgressTips show(Context context, OnCancelListener cancelListener) {

		ProgressTips dialog = new ProgressTips(context, R.style.ExecStyle);

		dialog.setContentView(R.layout.progresstips);

		dialog.setOnCancelListener(cancelListener);

		dialog.setCancelable(false);
		dialog.setCanceledOnTouchOutside(false);

		WindowManager.LayoutParams params = dialog.getWindow().getAttributes();

		params.gravity= Gravity.CENTER;
		params.dimAmount=0.2f;

		dialog.getWindow().setAttributes(params);

		dialog.show();

		return dialog;
	}	
}
